package com.smt.modules.app.config;

import com.smt.modules.app.controller.AppPushMessageController;
import com.smt.modules.bus.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * webSocket配置类
 *
 * @author zhangyi
 * @date 2018/11/9 11:54
 */
@Configuration
public class WebSocketConfig {
    @Bean
    public ServerEndpointExporter serverEndpointExporter(){
        return new ServerEndpointExporter();
    }

    /**
     * webSocket使用的是长连接，SpringBoot不能注入其实例,手动添加
     *
     * @param memberUserService
     * @param teamService
     * @param projectTaskService
     */
    @Autowired
    public void setMessageService(MemberUserService memberUserService, TeamService teamService,
                                  ProjectTaskService projectTaskService,SubtaskService subtaskService,
                                  MessageHandleService messageHandleService) {
        AppPushMessageController.memberUserService = memberUserService;
        AppPushMessageController.teamService = teamService;
        AppPushMessageController.projectTaskService = projectTaskService;
        AppPushMessageController.subtaskService = subtaskService;
        AppPushMessageController.messageHandleService = messageHandleService;
    }
}